import {Component, Input, OnInit} from '@angular/core';
import {ModalController} from '@ionic/angular';
import {UrlService} from '../../service/url.service';

@Component({
    selector: 'app-equipmenthelp',
    templateUrl: './equipmenthelp.component.html',
    styleUrls: ['./equipmenthelp.component.less'],
})
export class EquipmenthelpComponent implements OnInit {
    // 由componentProps传递的数据

    // 查询过滤条件 state = 1 启用等查询的数据
    @Input() queryData: object;

    title; // 帮助标题
    hurl; // 请求后端接口的 url -- 必须有
    hmethod;  // 请求后端接口的 请求方式 -- 必须有

    constructor(
        private url: UrlService,
        private modalController: ModalController,
    ) {
    }

    ngOnInit() {
        // console.log('上层帮助 ngOnInit');
        this.title = '设备选择';
        // 根据启用状态查询
        if (this.queryData) {
            this.hurl = this.url.host + '/boem/queryAllByState';
            this.hmethod = 'POST';
        } else {
            this.hurl = this.url.host + '/boem/equipmentManageFindAll';
            this.hmethod = 'GET';
        }
    }

    // 关闭modal
    dismiss(e) {
        // console.log('e=', e);
        // 使用注入的ModalController此页面
        // 可以“dismiss”自身并有选择地传回数据
        this.modalController.dismiss(e);
    }


}
